home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / network / ncsasock / sock_int.h < prev    next >
Text File  |  1996-07-05  |  6KB  |  165 lines

  1. /*
  2.  * BSD-style socket emulation library for the Mac
  3.  * Original author: Tom Milligan
  4.  * Current author: Charlie Reiman - creiman@ncsa.uiuc.edu
  5.  *
  6.  * This source file is placed in the public domian.
  7.  * Any resemblance to NCSA Telnet, living or dead, is purely coincidental.
  8.  *
  9.  *      National Center for Supercomputing Applications
  10.  *      152 Computing Applications Building
  11.  *      605 E. Springfield Ave.
  12.  *      Champaign, IL  61820
  13.  */
  14.  
  15. /*
  16.  * Internal prototypes for the socket library.
  17.  * There is duplication between socket.ext.h and socket.int.h, but
  18.  * there are too many complications in combining them.
  19.  */
  20.  
  21. #ifndef _SOCK_INT_
  22. #define _SOCK_INT_
  23.  
  24. typedef enum spin_msg
  25.     {
  26.     SP_MISC,            /* some weird thing */
  27.     SP_SELECT,            /* in a select call */
  28.     SP_NAME,            /* getting a host by name */
  29.     SP_ADDR,            /* getting a host by address */
  30.     SP_TCP_READ,        /* TCP read call */
  31.     SP_TCP_WRITE,        /* TCP write call */
  32.     SP_UDP_READ,        /* UDP read call */
  33.     SP_UDP_WRITE,        /* UDP write call */
  34.     SP_SLEEP            /* sleeping */
  35.     } spin_msg;
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. #ifndef __socket_ext__
  42. typedef int (*SpinFn)(spin_msg msg,long param);
  43. #endif /* __socket_ext__ */
  44.  
  45. /* spin routine prototype, doesn't work. Sigh. */
  46. /*extern int (*spinroutine)(spin_msg mesg,long param);*/
  47.  
  48. /* tcpglue.c */
  49.  
  50. OSErr xPBControlSync(TCPiopb *pb);
  51. OSErr xPBControl(TCPiopb *pb, TCPIOCompletionProc completion);
  52.  
  53.  
  54. OSErr xOpenDriver(void);
  55. OSErr xTCPCreate(int buflen, TCPNotifyProc notify, TCPiopb *pb);
  56. OSErr xTCPPassiveOpen(TCPiopb *pb, short port, TCPIOCompletionProc completion);
  57. OSErr xTCPActiveOpen(TCPiopb *pb, short port, long rhost, short rport, TCPIOCompletionProc completion);
  58. OSErr xTCPRcv(TCPiopb *pb, char *buf, int buflen, int timeout, TCPIOCompletionProc completion);
  59. OSErr xTCPNoCopyRcv(TCPiopb *,rdsEntry *,int,int,TCPIOCompletionProc);
  60. OSErr xTCPBufReturn(TCPiopb *pb,rdsEntry *rds,TCPIOCompletionProc completion);
  61. OSErr xTCPSend(TCPiopb *pb, wdsEntry *wds, Boolean push, Boolean urgent, TCPIOCompletionProc completion);
  62. OSErr xTCPClose(TCPiopb *pb,TCPIOCompletionProc completion);
  63. OSErr xTCPAbort(TCPiopb *pb);
  64. OSErr xTCPRelease(TCPiopb *pb);
  65. int xTCPBytesUnread(SocketPtr sp);
  66. int xTCPBytesWriteable(SocketPtr sp);
  67. int xTCPWriteBytesLeft(SocketPtr sp);
  68. int xTCPState(TCPiopb *pb);
  69. OSErr xUDPCreate(SocketPtr sp,int buflen,ip_port port);
  70. OSErr xUDPRead(SocketPtr sp,UDPIOCompletionProc completion);
  71. OSErr xUDPBfrReturn(SocketPtr sp);
  72. OSErr xUDPWrite(SocketPtr sp,ip_addr host,ip_port port,miniwds *wds,
  73.         UDPIOCompletionProc completion);
  74. OSErr xUDPRelease(SocketPtr sp);
  75. ip_addr xIPAddr(void);
  76. long xNetMask(void);
  77. unsigned short xMaxMTU(void);
  78.  
  79.  
  80. /* socket.tcp.c */
  81. pascal void sock_tcp_notify(
  82.     StreamPtr tcpStream,
  83.     unsigned short eventCode,
  84.     Ptr userDataPtr,
  85.     unsigned short terminReason,
  86.     struct ICMPReport *icmpMsg);
  87. int sock_tcp_new_stream(SocketPtr sp);
  88. int sock_tcp_connect(SocketPtr sp, struct sockaddr_in *addr);
  89. int sock_tcp_listen(SocketPtr sp);
  90. int sock_tcp_accept(SocketPtr sp, struct sockaddr_in *from, Int4 *fromlen);
  91. int sock_tcp_accept_once(SocketPtr sp, struct sockaddr_in *from, Int4 *fromlen);
  92. int sock_tcp_recv(SocketPtr sp, char *buffer, int buflen, int flags);
  93. int sock_tcp_can_read(SocketPtr sp);
  94. int sock_tcp_send(SocketPtr sp, char *buffer, int count, int flags);
  95. int sock_tcp_can_write(SocketPtr sp);
  96. int sock_tcp_close(SocketPtr sp);
  97.  
  98. /* socket.udp.c */
  99.  
  100. int sock_udp_new_stream(SocketPtr sp);
  101. int sock_udp_connect(SocketPtr sp,struct sockaddr_in *addr);
  102. int sock_udp_recv(SocketPtr sp, char *buffer, int buflen, int flags, struct sockaddr_in *from, int *fromlen);
  103. int sock_udp_can_recv(SocketPtr sp);
  104. int sock_udp_send(SocketPtr sp, struct sockaddr_in *to, char *buffer, int count, int flags);
  105. int sock_udp_can_send(SocketPtr sp);
  106. int sock_udp_close(SocketPtr sp);
  107.  
  108. /* socket.util.c */
  109.  
  110. int sock_init(void);
  111. void sock_close_all(void);
  112. int sock_free_fd(int f);
  113. void sock_dup_fd(int s,int s1);
  114. void sock_clear_fd(int s);
  115. void sock_init_fd(int s);
  116. int sock_err(int err_code);
  117. void sock_copy_addr(void *from, void *to, Int4 *tolen);
  118. void sock_dump(void);
  119. void sock_print(char *title, SocketPtr sp);
  120. StreamHashEntPtr sock_find_shep(StreamPtr);
  121. StreamHashEntPtr sock_new_shep(StreamPtr);
  122. void *sock_fetch_pb(SocketPtr);
  123.  
  124.  
  125. #ifdef NOTNOW_COMP_CODEWAR
  126. /* these are from sock_ext.h -- can't include w/ sock_int.h due to conflict of spin_msg dup !*/
  127. /* Socket.c */
  128.  
  129. int s_socket(Int4 domain, Int4 type, short protocol);
  130. int s_bind(Int4 s, struct sockaddr *name, Int4 namelen);
  131. int s_connect(Int4 s, struct sockaddr *addr, Int4 addrlen);
  132. int s_listen(Int4 s, Int4 qlen);
  133. int s_accept(Int4 s, struct sockaddr *addr, Int4 *addrlen);
  134. int s_accept_once(Int4 s, struct sockaddr *addr, Int4 *addrlen);
  135. int s_close(Int4 s);
  136. int s_read(Int4 s, void *buffer, Int4 buflen);
  137. int s_recv(Int4 s, void *buffer, Int4 buflen, Int4 flags);
  138. int s_recvfrom(Int4 s, void *buffer, Int4 buflen, Int4 flags, struct sockaddr *sa_from, Int4 *fromlen);
  139. int s_write(Int4 s, void *buffer, Int4 buflen);
  140. int s_writev(Int4 s, struct iovec *iov, Int4 count);
  141. int s_send(Int4 s, void *buffer, Int4 buflen, Int4 flags);
  142. int s_sendto (Int4 s, void *buffer, Int4 buflen, Int4 flags, struct sockaddr *to, Int4 tolen);
  143. int s_sendmsg(Int4 s,struct msghdr *msg,Int4 flags);
  144. int s_really_send(Int4 s, void *buffer, Int4 count, Int4 flags, struct sockaddr_in *to);
  145. int s_select(Int4 width, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
  146. int s_getdtablesize(void);
  147. int s_getsockname(Int4 s, struct sockaddr *name, Int4 *namelen);
  148. int s_getpeername(Int4 s, struct sockaddr *name, Int4 *namelen);
  149. int s_shutdown(Int4 s, Int4 how);
  150. int s_fcntl(Int4 s, unsigned Int4 cmd, Int4 arg); 
  151. int s_dup(Int4 s);
  152. int s_dup2(Int4 s, Int4 s1);
  153. int s_ioctl(Int4 d, Int4 request, Int4 *argp);  /* argp is really a caddr_t */
  154. int s_setsockopt(Int4 s, Int4 level, Int4 optname, char *optval, Int4 optlen);
  155. int s_setspin(SpinFn routine);
  156. SpinFn s_getspin(void);
  157.  
  158. #endif
  159.  
  160. #ifdef __cplusplus
  161. }
  162. #endif
  163.  
  164. #endif /*_SOCK_INT_*/
  165.